home *** CD-ROM | disk | FTP | other *** search
Text File | 1990-09-14 | 1.1 KB | 59 lines | [TEXT/MPS ] |
- /*
- File: TestHooks.cp
-
- Contains: MPW tool which demonstrates how to use the Hooks class.
-
- Written by: Jack Palevich
-
- Copyright: © 1990 by Apple Computer, Inc., all rights reserved.
-
- Change History:
-
- 2/18/90 JHP new today
-
- To Do:
- */
-
- #include <Stdio.h>
- #include <Resources.h>
- #include <Traps.h>
- #include <CursorCtl.h>
-
- #include "Hooks.h"
-
- pascal void HandleCursorTrap(short /* trap */, THookStackFrame* /* args */, void* userRefNum)
- {
- long* countPtr = (long*) userRefNum;
-
- (*countPtr)++;
-
- }
-
- int main()
- {
- long trapCount = 0;
- const short kSpinCount = 10000;
-
- printf("Installing hooks\n"); fflush(stdout);
-
- static const short kOurHookTraps[1] = { _SetCursor };
- THooks* cursorHook = new THooks(1, kOurHookTraps, HandleCursorTrap, &trapCount);
-
- printf("Calling SpinCursor %d times\n", kSpinCount); fflush(stdout);
-
- InitCursorCtl(nil);
-
- for ( short i = 0; i < kSpinCount; i++ )
- {
- SpinCursor(1);
- }
-
- printf("SetCursor was called %d times\n", trapCount);
-
- printf("Removing hooks\n"); fflush(stdout);
- delete cursorHook;
-
- printf("Exiting\n"); fflush(stdout);
- return 0;
- }
-